<?php

class model_config extends model
{

	public function save($config, $name, $app_dir = null)
	{
		$vars = get_object_vars($config);
		$buf = "<?php\r\n";
		$buf .= 'class config_'.$name."\r\n";
		$buf .= "{\r\n";

		foreach($vars as $key=>$val)
		{
			$buf .= '  public $'.$key.' = ';
			if( is_bool($val) )
			{	
				if($val)
					$buf .= 'true;';
				else
					$buf .= 'false;';
			}
			else if( is_int($val) || is_float($val) )
			{
				$buf .= $val.';';
			}
			else
			{
				$buf .= '\''.$val.'\';';
			}
			$buf .= "\r\n";
		}
		$buf .= "}\r\n";
		$buf .= '?>';
		
		if( $app_dir )
			file_put_contents( BONE_ROOT.DS.$app_dir.DS.'configs'.DS.$name.'.php', $buf);
		else
			file_put_contents( BONE_ROOT.DS.'configs'.DS.$name.'.php', $buf);
	
	}

}
?>